#include<iostream>
#include<vector>
#include<deque>
#include<climits>
using namespace std;


int shortestSubarray(vector<int>& nums, int k) 
{
    int n=nums.size();
    vector<long long> sums(n+1,0);
    deque<long long> dq;
    int ret=INT_MAX;
    for(int i=0;i<n;i++)
    {
        sums[i+1]=sums[i]+nums[i];
    }

    for(int i=0;i<=n;i++)
    {
        while(!dq.empty()&&sums[i]-sums[dq.front()]>=k)
        {
            ret=min(ret,i-dq.front());
            dq.pop_front();
        }

        while(!dq.empty()&&sums[i]<=sums[dq.back()])
        {
            dq.pop_back();
        }

        dq.push_back(i);
    }
    
    return ret==INT_MAX?-1:ret;
}

int main()
{
    int n,k;cin>>n>>k;
    vector<int>nums(n,0);
    for(int i=0;i<n;i++)
    {
        cin>>nums[i];
    }
    shortestSubarray(nums,k);
}